﻿<!--#include file="base.asp"-->
<%
''' SDCMS 广告
''' ==================================================================
''' 版权所有 http://www.sdcms.cn
''' ------------------------------------------------------------------
''' 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和使用；
''' 未经授权不允许对程序代码以任何形式任何目的的再发布。
''' ==================================================================
''' 编写: IT平民
''' 修改：IT平民 in 2014.07

	sub add_text_db()
		dim t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,code
		dim style:style=""
		t0=sdcms.enhtml(sdcms.fpost("t0",0))
		t1=sdcms.getint(sdcms.fpost("t1",0),0)
		t2=sdcms.enhtml(sdcms.fpost("t2",0))
		t3=sdcms.enhtml(sdcms.fpost("t3",0))
		t4=sdcms.fpost("t4",0)
		t5=sdcms.fpost("t5",0)
		t6=sdcms.enhtml(sdcms.fpost("t6",0))
		t7=sdcms.getint(sdcms.fpost("t7",0),12)
		t8=sdcms.enhtml(sdcms.fpost("t8",0))
		t9=sdcms.getint(sdcms.fpost("t9",0),0)
		t10=sdcms.getint(sdcms.fpost("t10",0),0)
		if sdcms.strlen(t0)=0 then sdcms.ajaxjson "&#24191;&#21578;&#21517;&#31216;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if sdcms.strlen(t4)=0 then sdcms.ajaxjson "&#38142;&#25509;&#25991;&#23383;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if sdcms.strlen(t5)=0 then sdcms.ajaxjson "&#38142;&#25509;&#32593;&#22336;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if t2="" then t2="1753-01-01"
		if t3="" then t3="9999-12-31"
		if sdcms.strlen(t7)>0 then
			style=style&"font-size:"&t7&"px;"
		end if
		if sdcms.strlen(t6)>0 then
			style=style&"color:"&t6&";"
		end if
		if style<>"" then
			style="style="""&style&""""
		end if
		code="<a href="""&t5&""" target=""_blank"" "&style&">"&t4&"</a>"
		dim data:data=array(array("title",t0,255),array("classid",t1,0),array("begindate",t2,0),array("overdate",t3,0),array("text",t4,0),array("url",t5,0),array("style",style,255),array("note",t8,0),array("ordnum",t9,10),array("islock",t10,0),array("code",code,0),array("adtype",1,0))
		if sdcms.db.dbnew("sd_expand_ad",data,"")=1 then
			sdcms.ajaxjson "保存成功",1
		end if
	end sub
	
	sub add_pic_db()
		dim t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,code
		t0=sdcms.enhtml(sdcms.fpost("t0",0))
		t1=sdcms.getint(sdcms.fpost("t1",0),0)
		t2=sdcms.enhtml(sdcms.fpost("t2",0))
		t3=sdcms.enhtml(sdcms.fpost("t3",0))
		t4=sdcms.fpost("t4",0)
		t5=sdcms.fpost("t5",0)
		t6=sdcms.getint(sdcms.fpost("t6",0),0)
		t7=sdcms.getint(sdcms.fpost("t7",0),0)
		t8=sdcms.enhtml(sdcms.fpost("t8",0))
		t9=sdcms.getint(sdcms.fpost("t9",0),0)
		t10=sdcms.getint(sdcms.fpost("t10",0),0)
		if sdcms.strlen(t0)=0 then sdcms.ajaxjson "&#24191;&#21578;&#21517;&#31216;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if sdcms.strlen(t4)=0 then sdcms.ajaxjson "&#22270;&#29255;&#22320;&#22336;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if sdcms.strlen(t5)=0 then sdcms.ajaxjson "&#38142;&#25509;&#32593;&#22336;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if t2="" then t2="1753-01-01"
		if t3="" then t3="9999-12-31"
		code="<a href="""&t5&""" target=""_blank""><img src="""&t4&""" width="""&t6&""" height="""&t7&""" border=""0""></a>"
		dim data:data=array(array("title",t0,255),array("classid",t1,0),array("begindate",t2,0),array("overdate",t3,0),array("fileurl",t4,0),array("url",t5,0),array("width",t6,4),array("height",t7,4),array("note",t8,0),array("ordnum",t9,10),array("islock",t10,0),array("code",code,0),array("adtype",2,0))
		if sdcms.db.dbnew("sd_expand_ad",data,"")=1 then
			dim cid:cid=sdcms.db.insertid("id","sd_expand_ad")
			deal_file cid,6
			sdcms.ajaxjson "保存成功",1
		end if
	end sub
	
	sub add_flash_db()
		dim t0,t1,t2,t3,t4,t6,t7,t8,t9,t10,code
		t0=sdcms.enhtml(sdcms.fpost("t0",0))
		t1=sdcms.getint(sdcms.fpost("t1",0),0)
		t2=sdcms.enhtml(sdcms.fpost("t2",0))
		t3=sdcms.enhtml(sdcms.fpost("t3",0))
		t4=sdcms.fpost("t4",0)
		t6=sdcms.getint(sdcms.fpost("t6",0),0)
		t7=sdcms.getint(sdcms.fpost("t7",0),0)
		t8=sdcms.enhtml(sdcms.fpost("t8",0))
		t9=sdcms.getint(sdcms.fpost("t9",0),0)
		t10=sdcms.getint(sdcms.fpost("t10",0),0)
		if sdcms.strlen(t0)=0 then sdcms.ajaxjson "&#24191;&#21578;&#21517;&#31216;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if sdcms.strlen(t4)=0 then sdcms.ajaxjson "&#70;&#108;&#97;&#115;&#104;&#22320;&#22336;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if t2="" then t2="1753-01-01"
		if t3="" then t3="9999-12-31"
		code="<embed src="""&t4&""" width="""&t6&""" height="""&t7&""" wmode=""transparent""></embed>"
		dim data:data=array(array("title",t0,255),array("classid",t1,0),array("begindate",t2,0),array("overdate",t3,0),array("fileurl",t4,0),array("width",t6,4),array("height",t7,4),array("note",t8,0),array("ordnum",t9,10),array("islock",t10,0),array("code",code,0),array("adtype",3,0))
		if sdcms.db.dbnew("sd_expand_ad",data,"")=1 then
			dim cid:cid=sdcms.db.insertid("id","sd_expand_ad")
			deal_file cid,6
			sdcms.ajaxjson "保存成功",1
		end if
	end sub
	
	sub add_code_db()
		dim t0,t1,t2,t3,t4,t5,t6,t7
		t0=sdcms.enhtml(sdcms.fpost("t0",0))
		t1=sdcms.getint(sdcms.fpost("t1",0),0)
		t2=sdcms.enhtml(sdcms.fpost("t2",0))
		t3=sdcms.enhtml(sdcms.fpost("t3",0))
		t4=sdcms.fpost("t4",0)
		t5=sdcms.fpost("t5",0)
		t6=sdcms.getint(sdcms.fpost("t6",0),0)
		t7=sdcms.getint(sdcms.fpost("t7",0),0)
		if sdcms.strlen(t0)=0 then sdcms.ajaxjson "&#24191;&#21578;&#21517;&#31216;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if sdcms.strlen(t4)=0 then sdcms.ajaxjson "&#24191;&#21578;&#20869;&#23481;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if t2="" then t2="1753-01-01"
		if t3="" then t3="9999-12-31"
		dim data:data=array(array("title",t0,255),array("classid",t1,0),array("begindate",t2,0),array("overdate",t3,0),array("code",t4,0),array("note",t5,0),array("ordnum",t6,10),array("islock",t7,0),array("adtype",4,0))
		if sdcms.db.dbnew("sd_expand_ad",data,"")=1 then
			sdcms.ajaxjson "保存成功",1
		end if
	end sub
	
	sub edit_text_db()
		dim t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,code
		dim style:style=""
		t0=sdcms.enhtml(sdcms.fpost("t0",0))
		t1=sdcms.getint(sdcms.fpost("t1",0),0)
		t2=sdcms.enhtml(sdcms.fpost("t2",0))
		t3=sdcms.enhtml(sdcms.fpost("t3",0))
		t4=sdcms.fpost("t4",0)
		t5=sdcms.fpost("t5",0)
		t6=sdcms.enhtml(sdcms.fpost("t6",0))
		t7=sdcms.getint(sdcms.fpost("t7",0),12)
		t8=sdcms.enhtml(sdcms.fpost("t8",0))
		t9=sdcms.getint(sdcms.fpost("t9",0),0)
		t10=sdcms.getint(sdcms.fpost("t10",0),0)
		if sdcms.strlen(t0)=0 then sdcms.ajaxjson "&#24191;&#21578;&#21517;&#31216;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if sdcms.strlen(t4)=0 then sdcms.ajaxjson "&#38142;&#25509;&#25991;&#23383;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if sdcms.strlen(t5)=0 then sdcms.ajaxjson "&#38142;&#25509;&#32593;&#22336;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if t2="" then t2="1753-01-01"
		if t3="" then t3="9999-12-31"
		if sdcms.strlen(t7)>0 then
			style=style&"font-size:"&t7&"px;"
		end if
		if sdcms.strlen(t6)>0 then
			style=style&"color:"&t6&";"
		end if
		if style<>"" then
			style="style="""&style&""""
		end if
		code="<a href="""&t5&""" target=""_blank"" "&style&">"&t4&"</a>"
		dim data,id
		id=sdcms.getint(sdcms.fget("id",0),0)
		data=array(array("title",t0,255,1),array("classid",t1,0,0),array("begindate",t2,0,1),array("overdate",t3,0,1),array("text",t4,0,1),array("url",t5,0,1),array("style",style,255,1),array("note",t8,0,1),array("ordnum",t9,10,0),array("islock",t10,0,0),array("code",code,0,1))
		if sdcms.db.dbupdate("sd_expand_ad","id="&id&"",data)=1 then
			sdcms.delcache "plug_ad_"&id
			sdcms.ajaxjson "保存成功",1
		end if
	end sub
	
	sub edit_pic_db()
		dim t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,code
		t0=sdcms.enhtml(sdcms.fpost("t0",0))
		t1=sdcms.getint(sdcms.fpost("t1",0),0)
		t2=sdcms.enhtml(sdcms.fpost("t2",0))
		t3=sdcms.enhtml(sdcms.fpost("t3",0))
		t4=sdcms.fpost("t4",0)
		t5=sdcms.fpost("t5",0)
		t6=sdcms.getint(sdcms.fpost("t6",0),0)
		t7=sdcms.getint(sdcms.fpost("t7",0),0)
		t8=sdcms.enhtml(sdcms.fpost("t8",0))
		t9=sdcms.getint(sdcms.fpost("t9",0),0)
		t10=sdcms.getint(sdcms.fpost("t10",0),0)
		if sdcms.strlen(t0)=0 then sdcms.ajaxjson "&#24191;&#21578;&#21517;&#31216;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if sdcms.strlen(t4)=0 then sdcms.ajaxjson "&#22270;&#29255;&#22320;&#22336;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if sdcms.strlen(t5)=0 then sdcms.ajaxjson "&#38142;&#25509;&#32593;&#22336;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if t2="" then t2="1753-01-01"
		if t3="" then t3="9999-12-31"
		code="<a href="""&t5&""" target=""_blank""><img src="""&t4&""" width="""&t6&""" height="""&t7&""" border=""0""></a>"
		dim data,id
		id=sdcms.getint(sdcms.fget("id",0),0)
		data=array(array("title",t0,255,1),array("classid",t1,0,0),array("begindate",t2,0,1),array("overdate",t3,0,1),array("fileurl",t4,0,1),array("url",t5,0,1),array("width",t6,6,0),array("height",t7,6,0),array("note",t8,0,1),array("ordnum",t9,10,0),array("islock",t10,0,0),array("code",code,0,1))
		if sdcms.db.dbupdate("sd_expand_ad","id="&id&"",data)=1 then
			sdcms.delcache "plug_ad_"&id
			sdcms.ajaxjson "保存成功",1
		end if
	end sub
	
	sub edit_flash_db()
		dim t0,t1,t2,t3,t4,t6,t7,t8,t9,t10,code
		t0=sdcms.enhtml(sdcms.fpost("t0",0))
		t1=sdcms.getint(sdcms.fpost("t1",0),0)
		t2=sdcms.enhtml(sdcms.fpost("t2",0))
		t3=sdcms.enhtml(sdcms.fpost("t3",0))
		t4=sdcms.fpost("t4",0)
		t6=sdcms.getint(sdcms.fpost("t6",0),0)
		t7=sdcms.getint(sdcms.fpost("t7",0),0)
		t8=sdcms.enhtml(sdcms.fpost("t8",0))
		t9=sdcms.getint(sdcms.fpost("t9",0),0)
		t10=sdcms.getint(sdcms.fpost("t10",0),0)
		if sdcms.strlen(t0)=0 then sdcms.ajaxjson "&#24191;&#21578;&#21517;&#31216;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if sdcms.strlen(t4)=0 then sdcms.ajaxjson "&#70;&#108;&#97;&#115;&#104;&#22320;&#22336;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if t2="" then t2="1753-01-01"
		if t3="" then t3="9999-12-31"
		code="<embed src="""&t4&""" width="""&t6&""" height="""&t7&""" wmode=""transparent""></embed>"
		dim data,id
		id=sdcms.getint(sdcms.fget("id",0),0)
		data=array(array("title",t0,255,1),array("classid",t1,0,0),array("begindate",t2,0,1),array("overdate",t3,0,1),array("fileurl",t4,0,1),array("width",t6,6,0),array("height",t7,6,0),array("note",t8,0,1),array("ordnum",t9,10,0),array("islock",t10,0,0),array("code",code,0,1))
		if sdcms.db.dbupdate("sd_expand_ad","id="&id&"",data)=1 then
			sdcms.delcache "plug_ad_"&id
			sdcms.ajaxjson "保存成功",1
		end if
	end sub
	
	sub edit_code_db()
		dim t0,t1,t2,t3,t4,t5,t6,t7
		t0=sdcms.enhtml(sdcms.fpost("t0",0))
		t1=sdcms.getint(sdcms.fpost("t1",0),0)
		t2=sdcms.enhtml(sdcms.fpost("t2",0))
		t3=sdcms.enhtml(sdcms.fpost("t3",0))
		t4=sdcms.fpost("t4",0)
		t5=sdcms.fpost("t5",0)
		t6=sdcms.getint(sdcms.fpost("t6",0),0)
		t7=sdcms.getint(sdcms.fpost("t7",0),0)
		if sdcms.strlen(t0)=0 then sdcms.ajaxjson "&#24191;&#21578;&#21517;&#31216;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if sdcms.strlen(t4)=0 then sdcms.ajaxjson "&#24191;&#21578;&#20869;&#23481;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if t2="" then t2="1753-01-01"
		if t3="" then t3="9999-12-31"
		dim data,id
		id=sdcms.getint(sdcms.fget("id",0),0)
		data=array(array("title",t0,255,1),array("classid",t1,0,0),array("begindate",t2,0,1),array("overdate",t3,0,1),array("code",t4,0,1),array("note",t5,0,1),array("ordnum",t6,10,0),array("islock",t7,0,0))
		if sdcms.db.dbupdate("sd_expand_ad","id="&id&"",data)=1 then
			sdcms.delcache "plug_ad_"&id
			sdcms.ajaxjson "保存成功",1
		end if
	end sub
	
	sub deldb()
		dim id:id=sdcms.getint(sdcms.fget("id",0),0)
		sdcms.db.dbdel "sd_expand_ad","id="&id
		deal_del_file id,6
		sdcms.delcache "plug_ad_"&id
		sdcms.echo "1"
	end sub
	
	sub doset()
		dim id:id=sdcms.enhtml(sdcms.fget("id",0))
		dim go:go=sdcms.enhtml(sdcms.fget("go",0))
		dim idarr:idarr=split(id,",")
		if ubound(idarr)<0 then
			sdcms.echo "0&#33267;&#23569;&#36873;&#25321;&#19968;&#26465;&#20449;&#24687;"
		else
			dim i
			for i=0 to ubound(idarr)
				if not isnumeric(idarr(i)) then
					sdcms.echo "0&#21442;&#25968;&#65306;"&id(i)&"&#19981;&#27491;&#30830;&#65292;&#35831;&#30830;&#35748;&#21518;&#20877;&#25805;&#20316;"
					exit sub
				end if
			next
			dim filed,result
			select case go
				case "islock":filed="islock":result=0
				case "nolock":filed="islock":result=1
				case else:sdcms.echo "0&#21442;&#25968;&#38169;&#35823;":exit sub
			end select
			sdcms.db.dbupdate "sd_expand_ad","id in("&id&")",array(array(filed,result,2,0))
			sdcms.echo "1"
		end if
	end sub
	
	sub delsome()
		dim id:id=sdcms.enhtml(sdcms.fget("id",0))
		dim idarr:idarr=split(id,",")
		if ubound(idarr)<0 then
			sdcms.echo "0&#33267;&#23569;&#36873;&#25321;&#19968;&#26465;&#20449;&#24687;"
		else
			dim i
			for i=0 to ubound(idarr)
				if not isnumeric(idarr(i)) then
					sdcms.echo "0&#21442;&#25968;&#65306;"&id(i)&"&#19981;&#27491;&#30830;&#65292;&#35831;&#30830;&#35748;&#21518;&#20877;&#25805;&#20316;"
					exit sub
				else
					sdcms.db.dbdel "sd_expand_ad","id="&idarr(i)&""
					deal_del_file idarr(i),6
				end if
			next
			sdcms.echo "1"
		end if
	end sub
	
	function ad_type(byval t0)
		select case t0
			case "1":ad_type="文字"
			case "2":ad_type="图片"
			case "3":ad_type="Flash"
			case else:ad_type="代码"
		end select
	end function
	
	function ad_url(byval t0)
		select case t0
			case "1":ad_url="text"
			case "2":ad_url="pic"
			case "3":ad_url="flash"
			case else:ad_url="code"
		end select
	end function
	
	islogin
	checkpagelever 41
	dim act:act=lcase(sdcms.fget("act",0))
	select case act
		case "add_text","add_pic","add_flash","add_code":load eval("theme_expand_ad_"&act)
		case "add_text_db":add_text_db
		case "add_pic_db":add_pic_db
		case "add_flash_db":add_flash_db
		case "add_code_db":add_code_db
		case "edit_text","edit_pic","edit_flash","edit_code","call"
			dim datadb,id,ad_style,thisdata
			id=sdcms.getint(sdcms.fget("id",0),0)
			datadb=sdcms.db.dbload("","title,classid,islock,ordnum,adtype,text,url,style,fileurl,width,height,code,begindate,overdate,note","sd_expand_ad","id="&id&"","")
			ad_style=datadb(7,0)
			thisdata=date()
			if sdcms.strlen(ad_style)>0 then
				ad_style=replace(ad_style,"style=""","")
				ad_style=replace(ad_style,"""","")
				if instr(ad_style,"font-size:")>0 then
					dim fontsize
					fontsize=left(mid(ad_style,11),2)
				end if
				if instr(ad_style,"color:")>0 then
					dim fontcolor
					fontcolor=replace(right(ad_style,8),";","")
				end if
			end if
			load eval("theme_expand_ad_"&act)
		case "edit_text_db":edit_text_db
		case "edit_pic_db":edit_pic_db
		case "edit_flash_db":edit_flash_db
		case "edit_code_db":edit_code_db
		case "del":deldb
		case "doset":doset
		case "delsome":delsome
		case else
			dim sqlwhere,nattitle,nat
			nat=sdcms.getint(sdcms.fget("nat",0),0)
			select case nat
				case "1":sqlwhere=" and islock=0":nattitle="性质:未审"
				case "2":sqlwhere=" and islock=1":nattitle="性质:已审"
				case "3":sqlwhere=" and not(date() between begindate and overdate)":nattitle="性质:过期"
				case "4":sqlwhere=" and adtype=1":nattitle="性质:文字广告"
				case "5":sqlwhere=" and adtype=2":nattitle="性质:图片广告"
				case "6":sqlwhere=" and adtype=3":nattitle="性质:Flash广告"
				case "7":sqlwhere=" and adtype=4":nattitle="性质:代码广告"
				case else:nattitle="按性质↓"
			end select
			load theme_expand_ad
	end select
	sdcms.db.dbclose
%>